'use strict';
yjx.filter('filterimgtag', [function () {
    var filterimgtag = function (text, reg1, reg2) {
        text = text || " ";
        reg1 = new RegExp("<//", "g");
        reg2 = new RegExp("//>", "g");
        text = text.replace(reg1, '<img src="' + ALISRC);
        text = text.replace(reg2, '">');
        return text;
    };
    return filterimgtag;

}]);

yjx.filter('filterimgsrc', [function () {
    var filterimgsrc = function (text, reg1, reg2) {
        text = text || " ";
        reg1 = new RegExp("</", "g");
        reg2 = new RegExp("/>", "g");
        text = text.replace(reg1, ALISRC);
        text = text.replace(reg2, '');
        return text;
    };
    return filterimgsrc;

}]);

yjx.filter('substring', [function () {
    var filter = function (text, len, tail) {
        var args = Array.prototype.slice.call(arguments);
        text = args[0] + '';
        len = args[1];
        tail = args[2];
        if (tail && text.length > len) {
            text = text.substr(0, len);
            text += tail;
        } else {
            text = text.substr(0, len);
        }
        return text;
    };
    return filter;
}]);

//html转义
yjx.filter('trustHtml', ["$sce", function ($sce) {
    return function (input) {
        return $sce.trustAsHtml(input);
    }
}]);

//回车符、空格转义
yjx.filter('enter', [function () {
    var filterEnter = function (text, reg1, reg2) {
        text = text || " ";
        reg1 = new RegExp(" ", "g");
        reg2 = new RegExp("\n", "g");
        text = text.replace(reg1, "&nbsp");    //空格
        text = text.replace(reg2, "<br />");   //回车符
        return text;
    };
    return filterEnter;
}]);


